namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0043 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Dispose",
                c => new
                    {
                        DisposeId = c.Int(nullable: false, identity: true),
                        DisposeDesc = c.String(),
                        DisposeDate = c.DateTime(),
                        AssetCode = c.String(),
                        FromIcmWhId = c.Int(),
                        FromJobsiteId = c.Int(),
                        FromOtherPlace = c.String(),
                        ToOtherSite = c.String(),
                        ToOtherPlace = c.String(),
                        DisposeTypeId = c.Int(),
                        ResTypeId = c.Int(nullable: false),
                        Remark = c.String(),
                        ApprovedBy = c.Int(),
                        ApprovedWhen = c.DateTime(),
                        DisposeStatus = c.String(),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.DisposeId)
                .ForeignKey("dbo.IcmMasResourceType", t => t.ResTypeId, cascadeDelete: true)
                .ForeignKey("dbo.IcmWarehouse", t => t.FromIcmWhId)
                .ForeignKey("dbo.hrm_mp_job_sites", t => t.FromJobsiteId)
                .ForeignKey("dbo.IcmMasLookUp", t => t.DisposeTypeId)
                .ForeignKey("dbo.hrm_ps_employees", t => t.ApprovedBy)
                .Index(t => t.ResTypeId)
                .Index(t => t.FromIcmWhId)
                .Index(t => t.FromJobsiteId)
                .Index(t => t.DisposeTypeId)
                .Index(t => t.ApprovedBy);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Dispose", new[] { "ApprovedBy" });
            DropIndex("dbo.Dispose", new[] { "DisposeTypeId" });
            DropIndex("dbo.Dispose", new[] { "FromJobsiteId" });
            DropIndex("dbo.Dispose", new[] { "FromIcmWhId" });
            DropIndex("dbo.Dispose", new[] { "ResTypeId" });
            DropForeignKey("dbo.Dispose", "ApprovedBy", "dbo.hrm_ps_employees");
            DropForeignKey("dbo.Dispose", "DisposeTypeId", "dbo.IcmMasLookUp");
            DropForeignKey("dbo.Dispose", "FromJobsiteId", "dbo.hrm_mp_job_sites");
            DropForeignKey("dbo.Dispose", "FromIcmWhId", "dbo.IcmWarehouse");
            DropForeignKey("dbo.Dispose", "ResTypeId", "dbo.IcmMasResourceType");
            DropTable("dbo.Dispose");
        }
    }
}
